<?php

use App\GlobalData;
use Swoole\Thread\Map;

return [
    'server'    => [
        [
            'host'      => '0.0.0.0',
            'port'      => 8832,
            'sock_type' => \App\ServerInterface::HTTP_SERVER,
            'callbacks' => [
                'request' => \App\HTTP\RequestHandler::class,
            ],
            'settings'  => [],
        ],
        [
            'host'      => '0.0.0.0',
            'port'      => 8833,
            'sock_type' => \App\ServerInterface::SWOOLE_SOCK_TCP,
            'callbacks' => [
                'Connect' => \App\TCP\ConnectHandler::class,
                'Receive' => \App\TCP\ReceiveHandler::class,
                'Close'   => \App\TCP\CloseHandler::class,
            ],
            'settings'  => [
                'heartbeat_idle_time'      => 600, // 表示一个连接如果600秒内未向服务器发送任何数据，此连接将被强制关闭
                'heartbeat_check_interval' => 60,  // 表示每60秒遍历一次
//                'open_eof_check'           => true,   //打开EOF检测
//                'package_eof'              => "\r\n", //设置EOF //暂时用这样的协议去拆分
            ],
        ],
    ],
    'settings'  => [
        'worker_num'     => 2,
        'bootstrap'      => CURRENT_FILE,
        'init_arguments' => function () {
            return GlobalData::init([new \App\CallBacks\GlobalDataInit(), 'handle']);
        },
    ],
    'callbacks' => [
        'Start'        => \App\CallBacks\Start::class,
        'ManagerStart' => \App\CallBacks\ManagerStart::class,
        'WorkerStart'  => \App\CallBacks\WorkerStart::class,
        'WorkerStop'   => \App\CallBacks\WorkerStop::class,
    ]
];
